@echo off
echo ===================================
echo  Starting Blog in PRODUCTION Mode
echo ===================================

echo.
echo [1/2] Building Frontend Application...
call npm run build --prefix frontend
if %errorlevel% neq 0 (
    echo.
    echo ERROR: Failed to build frontend.
    exit /b %errorlevel%
)
echo Frontend build completed successfully.

echo.
echo [2/2] Starting Production Server...
set NODE_ENV=production
call npm start --prefix backend

echo.
echo ===================================
echo  Blog is running in PRODUCTION mode.
echo  Access it at http://localhost:3001
echo ===================================
pause